<template>
  <div class="container">
    <div class="banner">
      <img :src="url" alt="banner"/>
    </div>
    <el-row :span="8" v-for="(page, index) of pages" :key="index" type="flex" >
      <el-col :span="6" v-for="(item, innerindex) of page" :key="item.clubId" :offset="innerindex > 0 ? 2 : 1">
        <!--        //code...-->
        <el-card class="box-card" shadow="hover">
          <div slot="header" class="clearfix" style="text-align: left">
            <span><h2>{{ item.clubName }}</h2></span>
          </div>
          <div class="text item">
            {{ item.introduce }}
          </div>
          <div>
            <el-button type="info" plain style="float: right;margin: 10px">详细信息<i
              class="el-icon-arrow-right el-icon--right"></i></el-button>
<!--            <button>阅读全文-->
<!--              <i class="el-icon-arrow-down"></i>-->
<!--            </button>-->
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {mapState} from "vuex";
import {getClublist} from '@/api/club'

export default {
  name: "ClubList",
  data() {
    return {
      url: require("@/assets/1.jpg"),
      currentDate: new Date(),
      clubList: []
    };
  },
  created() {
    this.getClubs();

  },
  computed: {
    pages() {
      const pages = []
      this.clubList.forEach((item, index) => {
        const page = Math.floor(index / 2)//4代表4条为一行，随意更改
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  },
  mounted() {
  },
  methods: {
    async getClubs() {
      await getClublist().then(res => {
        console.log(res[0].clubId);
        this.clubList = res;
        console.log(this.clubList[0].clubName);
      })
    },
  }
}
</script>

<style scoped>
/*@import "../../../style/common.scss";*/
/*@import "../../../style/index/index-main.scss";*/
/*card*/
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
  /*text-align: left;*/

}

.box-card {
  width: 480px;
  margin: 50px;
  background-color: #ffffff;
}

/*.time {*/
/*  font-size: 13px;*/
/*  color: #999;*/
/*}*/

/*.bottom {*/
/*  margin-top: 13px;*/
/*  line-height: 12px;*/
/*}*/

/*.button {*/
/*  padding: 0;*/
/*  float: right;*/
/*}*/

/*.image {*/
/*  width: 100%;*/
/*  display: block;*/
/*}*/

/*.clearfix:before,*/
/*.clearfix:after {*/
/*  display: table;*/
/*  content: "";*/
/*}*/

/*.clearfix:after {*/
/*  clear: both*/
/*}*/

/*img*/
.banner {
  height: 250px;
  width: 100%;
}

img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/*.title {*/
/*  float: top;*/
/*  position: absolute;*/
/*  margin-bottom: 200px;*/
/*}*/

el-row {
  /*margin: auto;*/
  /*margin-right: 300px;*/
  /*margin-left: 300px;*/
  width: 50%;
  /*border: 3px solid green;*/
  padding: 20px;
}

</style>
